module EmailWhitelist
  class AllowedEmail
    class << self
      def use_file(file)
        raise "File not found: #{file}" unless File.exists?(file)
        @whitelist_file = file
        @email_addresses = []
        File.open(@whitelist_file, 'r') do |f|
          f.each do |line|
            # skip blank lines and #comment lines
            unless line =~ /^\s*#/ || line =~ /^\s*$/
              @email_addresses << line.chomp.gsub(/\s/, '')
            end
          end
        end
      end
      def addresses
        @email_addresses
      end
    end
  end
end